package seatiger.tomcat.catalina;

import seatiger.tomcat.catalina.connector.NewRequest;
import seatiger.tomcat.catalina.connector.NewResponse;

import javax.servlet.ServletException;
import java.io.IOException;

/**
 * 阀
 */
public interface Valve {
    /**
     * 阀的信息
     *
     * @return
     */
    String getInfo();

    /**
     * 阀中的逻辑
     *
     * @param request
     * @param response
     * @param context
     * @throws IOException
     * @throws ServletException
     */
    @Deprecated
    void invoke(Request request, Response response, ValveContext context) throws IOException, ServletException;


    /**
     * 设置和这个阀关联的下一个阀
     * @param valve
     */
    void setNext(Valve valve);

    /**
     * 获取和这个阀关联的下一个阀
     * @return
     */
    Valve getNext();

    /**
     * 使用带缓冲request 处理业务逻辑
     * @param request
     */
    void invoke(NewRequest request, NewResponse response) throws IOException, ServletException;
}
